package com.java.multipledatasource.thread;

import java.util.concurrent.locks.LockSupport;

/**
 * @author hu
 * @version 1.0
 * @date 2021/1/16 0016 下午 6:29
 * @description
 */
public class Park {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(i);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if (i == 5) {
                    LockSupport.park();
                }
            }
        });
        t.start();
        // 类似 unpark 覆盖了 park
        LockSupport.unpark(t);
    }
}
